<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags"%>

<%@include file="/common/head.jsp" %>

<c:set var="module" value="product"/>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
		<form action="${ctx }/admin/product/save?id=${n.id }" id="detail-form" class="form-horizontal" method="post" onsubmit="return save()">
			<div id="specification"></div>
			<div class="form-group">
                 <label class="col-sm-2 control-label">品牌</label>
                 <div class="col-sm-10">
                 	<%-- <input type="text" class="form-control" name="brand.id" value="${n.brand.id }"> --%>
                 	<input type="hidden" id="brand-id" name="brand.id" value="${n.brand.id }" class="form-control">
                 	<input type="text"  placeholder="品牌" class="form-control" id="brand-name" name="brand.name" value="${n.brand.name }" 
                 		onclick="bring({
						                 	url:'${ctx}/admin/brand/list',
						                 	name: 'name',
						                 	idInput: 'brand-id',
						                 	nameInput: 'brand-name'
						                 	})" />
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">商品名称</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="name" value="${n.name }">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">副标题</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="subTitle" value="${n.subTitle }">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">商品分类</label>
                 <div class="col-sm-10">
                 	<%-- <input type="text" class="form-control" name="productCategory.id" value="${n.productCategory.id }"> --%>
                 	<input type="hidden" id="productCategory-id" name="productCategory.id" value="${n.productCategory.id }" class="form-control">
                 	<input type="text" placeholder="商品分类" class="form-control" id="productCategory-name" name="productCategory.name" value="${n.productCategory.name }" 
                 		onclick="bringTree({
						                 	url:'${ctx}/admin/productCategory/list',
						                 	name: 'realName',
						                 	idInput: 'productCategory-id',
						                 	nameInput: 'productCategory-name'
						                 	})" />
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">单位</label>
                 <div class="col-sm-10">
                 	<input type="text" class="form-control" name="unit" value="${n.unit }">
                 </div>
             </div>	
			<div class="form-group">
                 <label class="col-sm-2 control-label">上下架状态</label>
                 <div class="col-sm-10">
                 	<%-- <input type="text" class="form-control" name="sellingStatus" value="${n.sellingStatus }"> --%>
                 	${enum:detail('ProductSellingStatus', 'sellingStatus', n.sellingStatus) }
                 </div>
             </div>
             <div class="form-group">
                 <label class="col-sm-2 control-label">是否推荐首页</label>
                 <div class="col-sm-10">
                 	<select class="form-control" name="isRecommend">
	               		<option value="1" <c:if test="${n.isRecommend eq true }">selected="selected"</c:if>>是</option>
	               		<option value="0" <c:if test="${n.isRecommend eq false }">selected="selected"</c:if>>否</option>
	               	</select>
                 </div>
             </div>
           	<div class="form-group">
                 <label class="col-sm-2 control-label">商品首图</label>
                 <div class="col-sm-10">
		            <input type="hidden" name="headImage" id="headImage" value="${n.headImage }" />
                 	<div class="my-images" single="true" images="${n.headImage }" id="image1" field="headImage">
                 	</div>
                 </div>
             </div>
             <div class="form-group">
                 <label class="col-sm-2 control-label">商品多图</label>
                 <div class="col-sm-10">
		            <input type="hidden" name="images" id="images" value="${n.images }" />
                 	<div class="my-images" single="false" images="${n.images }" id="image2" field="images">
                 	</div>
                 </div>
             </div>
			<div class="form-group">
                 <label class="col-sm-2 control-label">详情</label>
                 <div class="col-sm-10">
                 	<input type="hidden" name="details" id="details" />
                 	<div class="summernote">${n.details }</div>
                 </div>
             </div>	
		</form>
</div>

<%@include file="/common/foot.jsp" %>

<script>
	$('.summernote').summernote({
	  airMode: false,
	  lang: 'zh-CN',
	  height: 300,
	  callbacks: {
	    onChange: function(contents, $editable) {
	      save();
	    }
	  }
	});
	
	function save() {
		var html = $('.summernote').summernote('code');
	  	$('#details').val(html);	  
	  	return true;
	}
	
	$(document).ready(function() {
		init_images('image1');
		init_images('image2');
	});
</script>
</body>
</html>
